VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
Begin VB.Form frmVerifyAddress 
   BackColor       =   &H00FFFFFF&
   Caption         =   "Verify Address"
   ClientHeight    =   4890
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   9030
   Icon            =   "frmVerifyAddress.frx":0000
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   ScaleHeight     =   4890
   ScaleWidth      =   9030
   StartUpPosition =   1  'CenterOwner
   Begin VB.CommandButton cmdCancel 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "&Cancel"
      Height          =   320
      Left            =   3480
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   9
      TabStop         =   0   'False
      Top             =   4440
      UseMaskColor    =   -1  'True
      Width           =   1200
   End
   Begin VB.CommandButton cmdVerify 
      Appearance      =   0  'Flat
      BackColor       =   &H00C0E0FF&
      Caption         =   "&Verify"
      Height          =   320
      Left            =   120
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   7
      TabStop         =   0   'False
      Top             =   4440
      UseMaskColor    =   -1  'True
      Width           =   1200
   End
   Begin VB.CommandButton cmdUpdate 
      Appearance      =   0  'Flat
      BackColor       =   &H00E0E0E0&
      Caption         =   "&Update"
      Height          =   320
      Left            =   1800
      MaskColor       =   &H0080C0FF&
      Style           =   1  'Graphical
      TabIndex        =   8
      TabStop         =   0   'False
      Top             =   4440
      UseMaskColor    =   -1  'True
      Width           =   1200
   End
   Begin VB.Frame Frame2 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Candidates"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000080FF&
      Height          =   4155
      Left            =   4860
      TabIndex        =   13
      Top             =   120
      Width           =   4035
      Begin VB.CommandButton cmdSelect 
         BackColor       =   &H00E0E0E0&
         Caption         =   "&Select"
         Height          =   315
         Index           =   1
         Left            =   120
         Style           =   1  'Graphical
         TabIndex        =   10
         Top             =   1200
         Width           =   1035
      End
      Begin VB.CommandButton cmdSelect 
         BackColor       =   &H00E0E0E0&
         Caption         =   "Select"
         Height          =   315
         Index           =   2
         Left            =   120
         Style           =   1  'Graphical
         TabIndex        =   12
         Top             =   3120
         Width           =   1035
      End
      Begin RichTextLib.RichTextBox txtCandidate 
         Height          =   1215
         Index           =   2
         Left            =   1260
         TabIndex        =   24
         TabStop         =   0   'False
         Top             =   2220
         Width           =   2595
         _ExtentX        =   4577
         _ExtentY        =   2143
         _Version        =   393217
         Enabled         =   -1  'True
         TextRTF         =   $"frmVerifyAddress.frx":1272
      End
      Begin RichTextLib.RichTextBox txtCandidate 
         Height          =   1155
         Index           =   1
         Left            =   1260
         TabIndex        =   23
         TabStop         =   0   'False
         Top             =   360
         Width           =   2595
         _ExtentX        =   4577
         _ExtentY        =   2037
         _Version        =   393217
         Enabled         =   -1  'True
         TextRTF         =   $"frmVerifyAddress.frx":12F4
      End
      Begin VB.Label lblMessage 
         Alignment       =   2  'Center
         BackColor       =   &H00FFFFFF&
         Height          =   615
         Index           =   2
         Left            =   1260
         TabIndex        =   27
         Top             =   3480
         Width           =   2595
      End
      Begin VB.Label lblMessage 
         Alignment       =   2  'Center
         BackColor       =   &H00FFFFFF&
         Height          =   615
         Index           =   1
         Left            =   1260
         TabIndex        =   26
         Top             =   1560
         Width           =   2595
      End
   End
   Begin VB.Frame Frame1 
      BackColor       =   &H00FFFFFF&
      Caption         =   "Recipient Address"
      BeginProperty Font 
         Name            =   "MS Sans Serif"
         Size            =   8.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000080FF&
      Height          =   4155
      Left            =   120
      TabIndex        =   11
      Top             =   120
      Width           =   4575
      Begin VB.TextBox f11 
         Height          =   315
         Left            =   1440
         TabIndex        =   1
         Top             =   1140
         Width           =   2955
      End
      Begin VB.TextBox f13 
         Height          =   315
         Left            =   1440
         TabIndex        =   2
         Top             =   1500
         Width           =   2955
      End
      Begin VB.TextBox f14 
         Height          =   315
         Left            =   1440
         TabIndex        =   3
         Top             =   1860
         Width           =   2955
      End
      Begin VB.TextBox f15 
         Height          =   315
         Left            =   1440
         TabIndex        =   4
         Top             =   2220
         Width           =   2955
      End
      Begin VB.TextBox f16 
         Height          =   315
         Left            =   1440
         TabIndex        =   5
         Top             =   2580
         Width           =   2955
      End
      Begin VB.TextBox f17 
         Height          =   315
         Left            =   1440
         TabIndex        =   6
         Top             =   2940
         Width           =   2955
      End
      Begin VB.TextBox f12 
         Height          =   315
         Left            =   1440
         TabIndex        =   0
         Top             =   780
         Width           =   2955
      End
      Begin VB.Label lblStatus 
         Alignment       =   2  'Center
         BackColor       =   &H00FFFFFF&
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H000000C0&
         Height          =   255
         Left            =   1440
         TabIndex        =   25
         Top             =   3540
         Width           =   1635
      End
      Begin VB.Label lblRecipientID 
         BackColor       =   &H00FFFFFF&
         Height          =   255
         Left            =   1440
         TabIndex        =   22
         Top             =   480
         Width           =   2955
      End
      Begin VB.Label Label8 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "State:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   21
         Top             =   2640
         Width           =   1095
      End
      Begin VB.Label Label7 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Zip:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   20
         Top             =   3000
         Width           =   1095
      End
      Begin VB.Label Label6 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Address 1:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   19
         Top             =   1560
         Width           =   1095
      End
      Begin VB.Label Label5 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Address 2:"
         Height          =   255
         Left            =   240
         TabIndex        =   18
         Top             =   1920
         Width           =   1095
      End
      Begin VB.Label Label4 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "City:"
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   255
         Left            =   240
         TabIndex        =   17
         Top             =   2280
         Width           =   1095
      End
      Begin VB.Label Label3 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Company:"
         Height          =   255
         Left            =   240
         TabIndex        =   16
         Top             =   1200
         Width           =   1095
      End
      Begin VB.Label Label2 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Contact:"
         Height          =   255
         Left            =   240
         TabIndex        =   15
         Top             =   840
         Width           =   1095
      End
      Begin VB.Label Label1 
         Alignment       =   1  'Right Justify
         BackColor       =   &H00FFFFFF&
         Caption         =   "Recipient ID:"
         Height          =   255
         Left            =   240
         TabIndex        =   14
         Top             =   480
         Width           =   1095
      End
   End
End
Attribute VB_Name = "frmVerifyAddress"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Option Compare Text

Const MODULE_NAME As String = "frmVerifyAddress"

Const MAX_CANDIDATES = 2

Dim m_str12(MAX_CANDIDATES) As String           'Contact
Dim m_str11(MAX_CANDIDATES) As String           'Company
Dim m_str13(MAX_CANDIDATES) As String           'Addr1
Dim m_str14(MAX_CANDIDATES) As String           'Addr2
Dim m_str15(MAX_CANDIDATES) As String           'City
Dim m_str16(MAX_CANDIDATES) As String           'St
Dim m_str17(MAX_CANDIDATES) As String           'Zip
Dim m_str1602(MAX_CANDIDATES) As String         'Score
Dim m_str1605(MAX_CANDIDATES) As String         'Rank
Dim m_str559(MAX_CANDIDATES) As String          'Messages
Dim m_str1604 As String                         'Actual Match Count
Dim m_strCandidateText(MAX_CANDIDATES) As String
'---------------------------------------------------------------------------------------
' Procedure : cmdSelect_Click()
' DateTime  : 9/14/2005
' Purpose   : One of the Select keys clicked. Puts the candidate's address in the Recipient
'             Address fields.
'---------------------------------------------------------------------------------------
'
Private Sub cmdSelect_Click(Index As Integer)
    
    On Error GoTo ErrorHandle

    Const PROCEDURE_NAME As String = "cmdSelect_Click"
    
    Call UpdateAddressFromCandidate(Index)
    
    'Enable Update button and highlight
    cmdUpdate.BackColor = &HC0E0FF
    cmdUpdate.Enabled = True
    
    Exit Sub

ErrorHandle:

    MsgBox Err.Description, vbCritical Or vbSystemModal, MODULE_NAME & "." & PROCEDURE_NAME

End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_Activate()
' DateTime  : 9/14/2005
' Purpose   : When the form is activated disable Update button, get address info from Ship
'             form.
'---------------------------------------------------------------------------------------
'
Private Sub Form_Activate()
    
    On Error GoTo ErrorHandle

    Const PROCEDURE_NAME As String = "Form_Initialize"

    cmdUpdate.Enabled = False
    cmdUpdate.BackColor = &HE0E0E0
    GetAddressFromShip
    
    f12.SetFocus
    
    Exit Sub

ErrorHandle:

    MsgBox Err.Description, vbCritical Or vbSystemModal, MODULE_NAME & "." & PROCEDURE_NAME

End Sub
'---------------------------------------------------------------------------------------
' Procedure : Form_KeyDown()
' DateTime  : 2/17/2005
' Purpose   : Enter key pressed sends a TAB to move to next field
'---------------------------------------------------------------------------------------
'
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If Not TypeOf Me.ActiveControl Is CommandButton Then
        If Shift = 0 And KeyCode = 13 Then
            SendKeys "{TAB}"
        End If
    End If
End Sub
'---------------------------------------------------------------------------------------
' Procedure : cmdUpdate_Click()
' DateTime  : 9/7/2005
' Purpose   : Updates the address on the Ship form, calls routine to set Ship form field
'             colors, hide candidates, and calls AfterAddrVerifyUpdate hook.
'---------------------------------------------------------------------------------------
'
Private Sub cmdUpdate_Click()

    On Error GoTo ErrorHandle

    Const PROCEDURE_NAME As String = "cmdUpdate_Click"
    
    SendAddressToShip
    Call SetShipFieldsBackColor(RGB(255, 250, 245), True) '&HC0E0FF)
    frmShip.StatusBar1.Panels(2) = m_str559(1)
    Call HideCandidate(1)
    Call HideCandidate(2)
    Call AfterAddrVerifyUpdate
    Me.Hide

    Exit Sub

ErrorHandle:

    MsgBox Err.Description, vbCritical Or vbSystemModal, MODULE_NAME & "." & PROCEDURE_NAME

End Sub
'---------------------------------------------------------------------------------------
' Procedure : cmdCancel_Click()
' DateTime  : 9/7/2005
' Purpose   : Hide form and returns to Ship form
'---------------------------------------------------------------------------------------
'
Private Sub cmdCancel_Click()

    On Error GoTo ErrorHandle

    Const PROCEDURE_NAME As String = "cmdCancel_Click"
    
    Call HideCandidate(1)
    Call HideCandidate(2)
    Call SetShipFieldsBackColor(vbWhite, False)
    frmShip.StatusBar1.Panels(2) = "Address not updated."
    Me.Hide
    
    Exit Sub

ErrorHandle:

    MsgBox Err.Description, vbCritical Or vbSystemModal, MODULE_NAME & "." & PROCEDURE_NAME

End Sub
'---------------------------------------------------------------------------------------
' Procedure : cmdVerify_Click()
' DateTime  : 9/7/2005
' Purpose   : Calls routine to send verification transaction
'---------------------------------------------------------------------------------------
'
Private Sub cmdVerify_Click()

    On Error GoTo ErrorHandle

    Const PROCEDURE_NAME As String = "cmdVerify_Click"
    
    'Initially disable Select buttons and RTBs
    Call HideCandidate(1)
    Call HideCandidate(2)
    lblStatus.Caption = "Searching..."
    Me.Refresh
    
    SendData BuildAddrVerifyTrans(f11, f13, f14, f15, Left(f16, 2), Left(f17, 5), Left(frmShip.f50, 2))

    Exit Sub

ErrorHandle:

    MsgBox Err.Description, vbCritical Or vbSystemModal, MODULE_NAME & "." & PROCEDURE_NAME

End Sub
'---------------------------------------------------------------------------------------
' Procedure : ShowCandidate()
' DateTime  : 9/7/2005
' Purpose   : Shows candidate in rich text box, enables controls and shows message
'---------------------------------------------------------------------------------------
'
Private Sub ShowCandidate(ByVal intIndex As Integer, _
                          ByVal strCandidateText As String, _
                          ByVal strMessageText As String)

    On Error GoTo ErrorHandle

    Const PROCEDURE_NAME As String = "ShowCandidate"
    
    cmdSelect(intIndex).Enabled = True
    txtCandidate(intIndex).Enabled = True
    txtCandidate(intIndex).Font.Bold = False
    lblMessage(intIndex).Visible = True
    txtCandidate(intIndex).TextRTF = ""
    txtCandidate(intIndex).TextRTF = strCandidateText
    lblMessage(intIndex).Caption = strMessageText

    Exit Sub

ErrorHandle:

    MsgBox Err.Description, vbCritical Or vbSystemModal, MODULE_NAME & "." & PROCEDURE_NAME

End Sub
'---------------------------------------------------------------------------------------
' Procedure : HideCandidate()
' DateTime  : 9/7/2005
' Purpose   : Disables controls and clears Candidate and hides message
'---------------------------------------------------------------------------------------
'
Private Sub HideCandidate(ByVal intIndex As Integer)
    
    On Error GoTo ErrorHandle
    
    Const PROCEDURE_NAME As String = "HideCandidate"
    
    cmdSelect(intIndex).Enabled = False
    txtCandidate(intIndex).TextRTF = ""
    txtCandidate(intIndex).Enabled = False
    lblMessage(intIndex).Visible = False

    Exit Sub

ErrorHandle:

    MsgBox Err.Description, vbCritical Or vbSystemModal, MODULE_NAME & "." & PROCEDURE_NAME

End Sub
'---------------------------------------------------------------------------------------
' Procedure : GetAddressFromShip()
' DateTime  : 9/7/2005
' Purpose   : Gets current address from Ship form
'---------------------------------------------------------------------------------------
'
Private Sub GetAddressFromShip()

    On Error GoTo ErrorHandle
    
    Const PROCEDURE_NAME As String = "GetAddressFromShip"
    
    With frmShip
        lblRecipientID = .f1
        f12 = .f12
        f11 = .f11
        f13 = .f13
        f14 = .f14
        f15 = .f15
        f16 = Left(.f16, 2)
        f17 = .f17
    End With

    Exit Sub

ErrorHandle:

    MsgBox Err.Description, vbCritical Or vbSystemModal, MODULE_NAME & "." & PROCEDURE_NAME

End Sub
'---------------------------------------------------------------------------------------
' Procedure : SendAddressToShip()
' DateTime  : 9/7/2005
' Purpose   : Puts current address on Verification form on Ship form
'---------------------------------------------------------------------------------------
'
Private Sub SendAddressToShip()

    On Error GoTo ErrorHandle
    
    Const PROCEDURE_NAME As String = "SendAddressToShip"
    
    With frmShip
        .f13 = f13
        .f14 = f14
        .f15 = f15
        .f16 = f16
        .f17 = Left(f17, 5)
    End With
    
    Exit Sub

ErrorHandle:

    MsgBox Err.Description, vbCritical Or vbSystemModal, MODULE_NAME & "." & PROCEDURE_NAME

End Sub
'---------------------------------------------------------------------------------------
' Procedure : UpdateAddressFromCandidate()
' DateTime  : 9/7/2005
' Purpose   : Puts candidate info on Verification form fields
'---------------------------------------------------------------------------------------
'
Private Sub UpdateAddressFromCandidate(ByVal intIndex As Integer)

    On Error GoTo ErrorHandle
    
    Const PROCEDURE_NAME As String = "UpdateAddressFromCandidate"
    
    f13 = m_str13(intIndex)
    
    If m_str14(intIndex) <> "" Then
        f14 = m_str14(intIndex)
    End If
    
    f15 = m_str15(intIndex)
    f16 = m_str16(intIndex)
    f17 = Left(m_str17(intIndex), 5)

    Exit Sub

ErrorHandle:

    MsgBox Err.Description, vbCritical Or vbSystemModal, MODULE_NAME & "." & PROCEDURE_NAME

End Sub
'---------------------------------------------------------------------------------------
' Procedure : GetCandidate()
' DateTime  : 9/7/2005
' Purpose   : Puts candidate info module level string variable
'---------------------------------------------------------------------------------------
'
Private Sub GetCandidate(ByVal intIndex As Integer)

    On Error GoTo ErrorHandle
    
    Const PROCEDURE_NAME As String = "GetCandidate"
    
    If m_str559(intIndex) = "" Then
        m_str559(intIndex) = "Valid."
    End If

    m_strCandidateText(intIndex) = FormatCandidateText(m_str13(intIndex), _
                                                       m_str14(intIndex), _
                                                       m_str15(intIndex), _
                                                       m_str16(intIndex), _
                                                       Left(m_str17(intIndex), 5))
    
    Exit Sub

ErrorHandle:

    MsgBox Err.Description, vbCritical Or vbSystemModal, MODULE_NAME & "." & PROCEDURE_NAME
    
End Sub
'---------------------------------------------------------------------------------------
' Procedure : FormatCandidateText()
' DateTime  : 9/7/2005
' Purpose   : Formats candidate text as RTF
'---------------------------------------------------------------------------------------
'
Private Function FormatCandidateText(ByVal strAddress1 As String, _
                                     ByVal strAddress2 As String, _
                                     ByVal strCity As String, _
                                     ByVal strState As String, _
                                     ByVal strZip As String) As String

    On Error GoTo ErrorHandle

    Const PROCEDURE_NAME As String = "FormatCandidateText"
    
    If Me.Visible Then
        If strAddress1 = f13 Then
            strAddress1 = "{ " & strAddress1 & "\line}"
        Else
            strAddress1 = "{\b\ " & strAddress1 & "\line}"
        End If
    
        If strAddress2 = f14 Then
            strAddress2 = "{ " & strAddress2 & "\line}"
        Else
            strAddress2 = "{\b\ " & strAddress2 & "\line}"
        End If
    
        If strCity = f15 Then
            strCity = "{ " & strCity & "}"
        Else
            strCity = "{\b\ " & strCity & "}"
        End If
    
        If strState = Left(f16, 2) Then
            strState = "{ " & strState & "\line}"
        Else
            strState = "{\b\ " & strState & "\line}"
        End If
    
        If Left(strZip, 5) = Left(f17, 5) Then
            strZip = "{ " & strZip & "}"
        Else
            strZip = "{\b\ " & strZip & "}"
        End If
    Else
        With frmShip
            If strAddress1 = .f13 Then
                strAddress1 = "{ " & strAddress1 & "\line}"
            Else
                strAddress1 = "{\b\ " & strAddress1 & "\line}"
            End If
        
            If strAddress2 = .f14 Then
                strAddress2 = "{ " & strAddress2 & "\line}"
            Else
                strAddress2 = "{\b\ " & strAddress2 & "\line}"
            End If
        
            If strCity = .f15 Then
                strCity = "{ " & strCity & "}"
            Else
                strCity = "{\b\ " & strCity & "}"
            End If
        
            If strState = Left(.f16, 2) Then
                strState = "{ " & strState & "\line}"
            Else
                strState = "{\b\ " & strState & "\line}"
            End If
        
            If Left(strZip, 5) = Left(.f17, 5) Then
                strZip = "{ " & strZip & "}"
            Else
                strZip = "{\b\ " & strZip & "}"
            End If
        End With
    End If
        
    FormatCandidateText = "{" & _
                            strAddress1 & _
                            strAddress2 & _
                            strCity & ", " & strState & _
                            strZip & _
                            "}"

    Exit Function

ErrorHandle:

    MsgBox Err.Description, vbCritical Or vbSystemModal, MODULE_NAME & "." & PROCEDURE_NAME

End Function
'---------------------------------------------------------------------------------------
' Procedure : AddrVerifyReply()
' DateTime  : 9/7/2005
' Modified  : 4/4/2007
' Purpose   : Parses the Address Verification reply
'---------------------------------------------------------------------------------------
'
Public Sub AddrVerifyReply()

    Dim i As Integer
    Dim j As Integer
    
    'Clear vars before getting new values
    Call ClearVerifyVars
    
    If g_str3 = "" Then
        With frmShip.g_clsParser
            For i = 0 To .TotalFields - 1
                Select Case .Field(i)
                    Case "1604"
                        m_str1604 = .Data(i)
                End Select
            Next
            'If there are matches, get candidates
            If Val(m_str1604) > 0 Then
                For i = 0 To .TotalFields - 1
                    For j = 1 To Val(m_str1604)
                        Select Case .Field(i)
                            Case "11-" & Trim(Str(j))
                                m_str11(j) = .Data(i)
                            Case "12-" & Trim(Str(j))
                                m_str12(j) = .Data(i)
                            Case "13-" & Trim(Str(j))
                                m_str13(j) = .Data(i)
                            Case "14-" & Trim(Str(j))
                                m_str14(j) = .Data(i)
                            Case "15-" & Trim(Str(j))
                                m_str15(j) = .Data(i)
                            Case "16-" & Trim(Str(j))
                                m_str16(j) = .Data(i)
                            Case "17-" & Trim(Str(j))
                                m_str17(j) = .Data(i)
                            Case "559-" & Trim(Str(j))
                                m_str559(j) = .Data(i)
                            Case "1602-" & Trim(Str(j))
                                m_str1602(j) = .Data(i)
                            Case "1605-" & Trim(Str(j))
                                m_str1605(j) = .Data(i)
                        End Select
                    Next
                Next
            End If
        End With
        
        '6/30/06 moved this outside For/Next statement
        If g_blnBatch Then
            If m_str559(1) = "" Then
                WriteAddrVerifyValid
            Else
                WriteAddrVerifySoftError
            End If
        Else
            For i = 1 To Val(m_str1604)
                GetCandidate (i)
                ShowCandidate i, m_strCandidateText(i), m_str559(i)
                lblStatus.Caption = "Complete."
            Next
        End If
    
    Else
        If g_blnBatch Then
            WriteAddrVerifyError
        Else
            lblMessage(1).Visible = True
            lblMessage(1).Caption = "Unable to verify address."
            With frmShip
                .StatusBar1.Panels(2) = "Address Verification Error"
                .StatusBar1.Panels(3) = g_str3
            End With
        End If
    End If
    
    With frmShip
        If Not g_blnBatch Then
            If .mnuAutoVerify.Checked Then Call AutoVerify
            .EnableButtons
            '20070404-01 - moved the hook calls here
            If g_str3 <> "" Then
                'Pass 3 indicating hard error
                Call AfterAddrVerify(3)
            ElseIf m_str559(1) <> "" Then
                'Pass 2 indicating soft error
                Call AfterAddrVerify(2)
            Else
                'Pass 1 indicating address verified
                Call AfterAddrVerify(1)
            End If
        
        End If
    End With
    
    g_str3 = ""

End Sub
'---------------------------------------------------------------------------------------
' Procedure : AutoVerify()
' DateTime  : 9/7/2005
' Purpose   : If no candidates are found set Ship fields colors to grey, else if the
'             soft error is not "Valid." show Verify Address form, else set Ship fields
'             color to white and update messages.
'---------------------------------------------------------------------------------------
'
Private Sub AutoVerify()
    With frmShip
        If Val(m_str1604) = 0 Then
            Call SetShipFieldsBackColor(&HF0F0F0, True)
        Else
            If m_str559(1) <> "Valid." Then
                Me.Show vbModeless, frmShip
            Else
                Call SetShipFieldsBackColor(&HFFFFFF, False)
                .StatusBar1.Panels(2) = "Address Verified!"
            End If
            .StatusBar1.Panels(2) = "Verification Complete!"
        End If
    End With
End Sub
'---------------------------------------------------------------------------------------
' Procedure : SetShipFieldsBackColor()
' DateTime  : 9/7/2005
' Purpose   : Sets Ship fields colors to color passed and sets the fonts to bold if
'             True passed.
'---------------------------------------------------------------------------------------
'
Public Sub SetShipFieldsBackColor(ByVal lngColor As Long, ByVal blnBold As Boolean)
    With frmShip
        Call SetBackcolor(.f13, lngColor)
        Call SetBackcolor(.f14, lngColor)
        Call SetBackcolor(.f15, lngColor)
        Call SetBackcolor(.f16, lngColor)
        Call SetBackcolor(.f17, lngColor)
        .f13.FontBold = blnBold
        .f14.FontBold = blnBold
        .f15.FontBold = blnBold
        .f16.FontBold = blnBold
        .f17.FontBold = blnBold
    End With
    
End Sub
'---------------------------------------------------------------------------------------
' Procedure : ClearVerifyVars()
' DateTime  : 9/7/2005
' Purpose   : Clear the variables used in verification.
'---------------------------------------------------------------------------------------
'
Private Sub ClearVerifyVars()
    Dim i As Integer
    
    For i = 0 To Val(m_str1604)
        m_str12(i) = ""
        m_str11(i) = ""
        m_str13(i) = ""
        m_str14(i) = ""
        m_str15(i) = ""
        m_str16(i) = ""
        m_str17(i) = ""
        m_str1602(i) = ""
        m_str1605(i) = ""
        m_str559(i) = ""
        m_strCandidateText(i) = ""
    Next
    
    m_str1604 = ""

End Sub
'---------------------------------------------------------------------------------------
' Procedure : WriteAddrVerifyValid()
' DateTime  : 9/15/2005
' Purpose   : Creates Batch Addr Verify valid file.
'---------------------------------------------------------------------------------------
'
Private Sub WriteAddrVerifyValid()
    Dim strPath As String
    Dim strLineOut As String
    Dim i As Integer
    
    On Error GoTo EH
    
    With frmSetup
        
        'Set path to program path or File Path defined is Setup Batch Defaults tab
        strPath = IIf(.txtFilesPath = "", App.Path, .txtFilesPath)
        
    End With
    
    'Increment shipped counter
    g_lngShipCount = g_lngShipCount + 1
    
    'Update Batch tab with total
    With frmShip
        .txtTotalRecords = Str(g_lngShipCount + g_lngErrorCount + g_lngSoftErrorCount)
    End With

    'Write reply fields to output file
    Open strPath & "\AddrVerifyValid_" & Format(Date, "YYYYMMDD") & ".txt" For Append As #1
    Print #1, g_strLine
    Close #1
    
    Exit Sub
EH:
     MsgBox Err.Description, vbCritical, "frmAddrVerify:WriteAddrVerifyValid"

End Sub
'---------------------------------------------------------------------------------------
' Procedure : WriteAddrVerifySoftError()
' DateTime  : 9/15/2005
' Purpose   : Creates Batch Addr Verify soft error file.
'---------------------------------------------------------------------------------------
'
Private Sub WriteAddrVerifySoftError()
    Dim strPath As String
    Dim strLineOut As String
    Dim strDelimOut As String
    Dim strQualOut As String
    Dim intUboundOutputFlds As Integer
    Dim i As Integer
    
    On Error GoTo EH
    
    With frmSetup
        
        'Get the output delimiter
        Select Case .cboDelimOut
            Case "Comma"
                strDelimOut = ","
            Case "Tab"
                strDelimOut = vbTab
            Case "Pipe"
                strDelimOut = "|"
            Case "Tilde"
                strDelimOut = "`"
        End Select
        'Get output text qualifier
        strQualOut = IIf(.cboQualOut = "None", "", .cboQualOut)
        
        'Set path to program path or File Path defined is Setup Batch Defaults tab
        strPath = IIf(.txtFilesPath = "", App.Path, .txtFilesPath)
        
        '10/17/05 Added original line Build soft message and address fields
        strLineOut = strLineOut & strQualOut & m_str559(1) & strQualOut & strDelimOut
        strLineOut = strLineOut & g_strLine & strDelimOut & strQualOut & "Postal Fields" & strQualOut & strDelimOut
        strLineOut = strLineOut & strQualOut & m_str11(1) & strQualOut & strDelimOut
        strLineOut = strLineOut & strQualOut & m_str13(1) & strQualOut & strDelimOut
        strLineOut = strLineOut & strQualOut & m_str14(1) & strQualOut & strDelimOut
        strLineOut = strLineOut & strQualOut & m_str15(1) & strQualOut & strDelimOut
        strLineOut = strLineOut & strQualOut & m_str16(1) & strQualOut & strDelimOut
        strLineOut = strLineOut & strQualOut & Left(m_str17(1), 5) & strQualOut & strDelimOut
        
    End With
    
    'Remove last delimiter
    strLineOut = Left(strLineOut, Len(strLineOut) - 1)
    
    'Increment shipped counter
    g_lngSoftErrorCount = g_lngSoftErrorCount + 1
    
    'Update Batch tab with totals
    With frmShip
        .txtNumShipped = Str(g_lngSoftErrorCount)
        .txtTotalRecords = Str(g_lngShipCount + g_lngErrorCount + g_lngSoftErrorCount)
    End With

    'Write reply fields to output file
    Open strPath & "\AddrVerifySoftErrors_" & Format(Date, "YYYYMMDD") & ".txt" For Append As #1
    Print #1, strLineOut
    Close #1
    
    Exit Sub
EH:
     MsgBox Err.Description, vbCritical, "frmAddrVerify:WriteAddrVerifyReply"

End Sub
'---------------------------------------------------------------------------------------
' Procedure : WriteAddrVerifyReply()
' DateTime  : 9/15/2005
' Purpose   : Creates Batch Addr Verify error file.
'---------------------------------------------------------------------------------------
'
Private Sub WriteAddrVerifyError()
    Dim strQualOut As String
    Dim strPath As String
    Dim strDelimOut As String
    
    On Error GoTo EH
    
    With frmSetup
        'Set the delimiter in the input transaction
        Select Case .cboDelimOut
            Case "Comma"
                strDelimOut = ","
            Case "Tab"
                strDelimOut = vbTab
            Case "Pipe"
                strDelimOut = "|"
            Case "Tilde"
                strDelimOut = "`"
        End Select
        
        'Get output text qualifier
        strQualOut = IIf(.cboQualOut = "None", "", .cboQualOut)
    
    End With
    
    'Set path to program path or File Path defined on Setup Batch Defaults tab
    If frmSetup.txtFilesPath = "" Then
        strPath = App.Path
    Else
        strPath = frmSetup.txtFilesPath
    End If
    
    With frmShip
        'Write error message and transaction text to file
        Open strPath & "\AddrVerifyErrors_" & Format(Date, "YYYYMMDD") & ".txt" For Append As #1
        'Added code to handle rating errors when performing Batch Error Check
            
        Print #1, strQualOut & g_str3 & strQualOut & strDelimOut & g_strLine
        g_lngErrorCount = g_lngErrorCount + 1
        Close #1
        
        .txtNumErrors = Str(g_lngErrorCount)
        .txtTotalRecords = Str(g_lngShipCount + g_lngErrorCount + g_lngSoftErrorCount)
    End With
    
    Exit Sub
EH:
     MsgBox Err.Description, vbCritical, "frmAddrVerify:WriteAddrVerifyError"

End Sub
'---------------------------------------------------------------------------------------
' Module    : GotFocus - textboxes
' DateTime  : 8/29/2005
' Author    : Chris Elwell
' Purpose   : The subroutines below call a routine to select all text in the text box
'             passed to the sub.
'---------------------------------------------------------------------------------------
'
Private Sub f12_GotFocus()
    Call SelectAllText(f12)
End Sub

Private Sub f11_GotFocus()
    Call SelectAllText(f11)
End Sub

Private Sub f13_GotFocus()
    Call SelectAllText(f13)
End Sub

Private Sub f14_GotFocus()
    Call SelectAllText(f14)
End Sub

Private Sub f15_GotFocus()
    Call SelectAllText(f15)
End Sub

Private Sub f16_GotFocus()
    Call SelectAllText(f16)
End Sub

Private Sub f17_GotFocus()
    Call SelectAllText(f17)
End Sub

